using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace GoobizFrame.Windows.Controls.TouchscreenKeyboard
{
    public partial class NumericBoard : UserControl
    {
        private string pvtKeyboardKeyPressed = "";
        public DevExpress.XtraEditors.TextEdit txtNumber;

        public NumericBoard()
        {
            InitializeComponent();
        }

        [Category("Mouse"), Description("Return value of mouseclicked key")]
        public event KeyboardDelegate UserKeyPressed;
        protected virtual void OnUserKeyPressed(KeyboardEventArgs e)
        {
            if (UserKeyPressed != null)
                UserKeyPressed(this, e);
        }

      
        private string HandleTheMouseClick(System.Windows.Forms.Control btn)
        {
            string Keypressed = null;
            switch (btn.Text)
            {
                case ".":
                case "0":                
                case "1":
                case "2":
                case "3":
                case "4":
                case "5":
                case "6":
                case "7":
                case "8":
                case "9":
                    Keypressed = btn.Text;
                    break;

                case "00":
                case "000":
                case "<<=":
                    Keypressed = "{BACKSPACE}";
                    break;
                case "Enter":
                    Keypressed = "{ENTER}";
                    break;
                case "Clear":
                    break;
            }
            return Keypressed;
        }

        
       

        private void button_MouseClick(object sender, MouseEventArgs e)
        {
            pvtKeyboardKeyPressed = HandleTheMouseClick((System.Windows.Forms.Control)sender);

            KeyboardEventArgs dea = new KeyboardEventArgs(pvtKeyboardKeyPressed);

            OnUserKeyPressed(dea);
        }

        private void button14_MouseClick(object sender, MouseEventArgs e)
        {
            KeyboardEventArgs dea = new KeyboardEventArgs("0");
            OnUserKeyPressed(dea);
            OnUserKeyPressed(dea);
        }

        private void button15_MouseClick(object sender, MouseEventArgs e)
        {
            KeyboardEventArgs dea = new KeyboardEventArgs("0");
            OnUserKeyPressed(dea);
            OnUserKeyPressed(dea);
            OnUserKeyPressed(dea);
        }

        private void button12_MouseClick(object sender, MouseEventArgs e)
        {
            if (txtNumber != null)
                txtNumber.Text = "";
        }

       
    }
}
